package ooday03;

/** 测试类 */
public class Test {
    public static void main(String[] args) {
        Dog[] dogs = new Dog[3];//创建一个Dog类型数组，里面有三个元素，初始值为null
        dogs[0] = new Dog("小黑",1,"黑");//给第一个元素传参
        dogs[1] = new Dog("小灰",2,"灰");//给第二个元素传参
        dogs[2] = new Dog("小白",3,"白");//给第三个元素传参
        System.out.println(dogs[0].name);//输出第一只狗的名字
        dogs[1].age = 18;//修改第二只狗的年龄为18岁
        dogs[2].swim();//第三只狗在游泳
        for(int i = 0;i<dogs.length;i++){
            System.out.println(dogs[i].name);//输出每只狗的名字
            dogs[i].eat();//每只狗吃饭
        }

        Chick[] chicks = new Chick[2];
        chicks[0] = new Chick("坤坤",1111,"白");//给第一个元素传参
        chicks[1] = new Chick("蔡蔡",2222,"黑");//给第二个元素传参
        for(int i = 0;i<chicks.length;i++){
            chicks[i].drink();//每只鸡喝水
        }

        Fish[] fish = new Fish[4];
        fish[0] = new Fish("金金1",18,"青");//给第一个元素传参
        fish[1] = new Fish("金金2",19,"橙");//给第二个元素传参
        fish[2] = new Fish("金金3",20,"黄");//给第三个元素传参
        fish[3] = new Fish("金金4",21,"绿");//给第四个元素传参
        for(int i = 0;i<fish.length;i++){
            fish[i].eat();//每条鱼吃饭
        }
    }
}
